//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#ifndef __IME_H__
#define __IME_H__

#include <driver.h>
#include <linknode.h>
#include "drv_queue.h"

class CIME: public CDeviceDriver
{
public:
    CARAPI Read(
        /* [in] */  Int64 offset,
        /* [in] */  Int32 numberOfBytesToRead,
        /* [out] */ MemoryBuf * pData,
        /* [out] */ IEvent * * ppCompletionEvent);

    CARAPI Write(
        /* [in] */  Int64 offset,
        /* [in] */ const  MemoryBuf & ebbData,
        /* [out] */ Int32 * pNumberOfBytesWritten,
        /* [out] */ IEvent * * ppCompletionEvent);

    CARAPI Control(
        /* [in] */  Handle32 controlCode,
        /* [in] */ const  MemoryBuf & ebbInData,
        /* [out] */ MemoryBuf * pOutData,
        /* [out] */ IEvent * * ppCompletionEvent);

    void Dispose();
    
    ECode   Initialize();

public:
    STATIC ECode S_Create(
        /* [in] */ Int32 environmentId,
        /* [out] */ IDeviceDriver ** ppMouse);

    STATIC CIME * S_Get(
        /* [in] */ Int32 environmentId);
private:
    CIME(Int32 environmentId)
         : m_environmentId(environmentId) {}
public:
    virtual ~CIME();
    
private:
    Queue m_inputStrQueue;
    Int32         m_environmentId;
    PVoid m_hEvent;
    bool m_isRunning;
public:
    bool m_readAbortFlag;
};


#endif //__IME_H__

